﻿<UserControl x:Class="Skugo.StandardPlugins.TreeForm"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <TreeView AllowDrop="True" HorizontalAlignment="Stretch" Name="View" VerticalAlignment="Stretch" PreviewMouseLeftButtonDown="View_PreviewMouseLeftButtonDown" MouseMove="View_MouseMove">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Children}">

                    <StackPanel AllowDrop="True" Orientation="Horizontal">
                        <Image AllowDrop="True" Stretch="None" Margin="0, 0, 4, 0" Source="{Binding Icon}" />
                        <TextBox  AllowDrop="True" LostFocus="TextBox_LostFocus" Mouse.MouseDown="OnTextMouseDown" Mouse.MouseUp="OnTextMouseUp" Padding="0" Focusable="False" Cursor="Arrow" Background="{x:Null}" BorderThickness="0" IsReadOnly="True" IsReadOnlyCaretVisible="False" Margin="0, 0, 2, 0" Text="{Binding Name}" />
                    </StackPanel>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>

            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">

                    <EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick" />

                    <!-- Style for the selected item -->
                    <Setter Property="BorderThickness" Value="1"/>
                    <Style.Triggers>
                        <!-- Selected and has focus -->
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="BorderBrush" Value="#7DA2CE"/>
                        </Trigger>
                        <!-- Selected but does not have the focus -->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True"/>
                                <Condition Property="IsSelectionActive" Value="False"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" Value="#D9D9D9"/>
                        </MultiTrigger>
                    </Style.Triggers>
                    <Style.Resources>
                        <Style TargetType="Border">
                            <Setter Property="CornerRadius" Value="2"/>
                        </Style>
                    </Style.Resources>
                </Style>
            </TreeView.ItemContainerStyle>
            
            <TreeView.Resources>
                <!-- Brushes for the selected item -->
                <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0">
                    <GradientStop Color="#FFDCEBFC" Offset="0"/>
                    <GradientStop Color="#FFC1DBFC" Offset="1"/>
                </LinearGradientBrush>
                <LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0">
                    <GradientStop Color="#FFF8F8F8" Offset="0"/>
                    <GradientStop Color="#FFE5E5E5" Offset="1"/>
                </LinearGradientBrush>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Black" />
            </TreeView.Resources>

        </TreeView>
    </Grid>
</UserControl>
